<template>
	<view class="content">
		<uni-section title="账号" sub-title=" " type="line">
			<view class="uni-title">{{email}}</view>
		</uni-section>
		<uni-section title="令牌" sub-title=" " type="square">
			<uni-countdown ref="countdown" :show-day="false" :second="second" color="#FFFFFF"
				background-color="#007AFF" />{{token}}
		</uni-section>
	</view>
</template>

<script>
	import {
		totpgener
	} from "@/common/totp.js"
	export default {
		data() {
			return {
				email: "",
				secret: "",
				token: "",
				second: 0
			}
		},
		onLoad(params) {
			this.email = params.email;
			this.secret = params.secret;
			this.token = totpgener(this.secret);
			this.second = 30;
			let that = this;
			setInterval(function() {
				that.token = totpgener(that.secret);
				that.second = 30;
				that.$refs.countdown.update()
			}, 30000);
		},
		methods: {

		}
	}
</script>

<style>
	.content {
		padding: 20rpx;
	}
</style>